import java.util.HashMap;
import java.util.List;

/**
 * @Author liangzai
 * @Description:
 */
public class Test {
    public int lengthOfLongestSubstring(String s) {
        HashMap<Character,Integer> map = new HashMap<>();
        int max = 1;
        int count = 0;

        for (int i = 0; i < s.length(); i++) {
            if(!map.containsKey(s.charAt(i))){
                map.put(s.charAt(i),1);
                count++;
            }else {
                map = new HashMap<>();
                if(max<=count){
                    max = count;
                }
                count = 0;
            }
        }
        return max;
    }

    public String destCity(List<List<String>> paths) {
        HashMap<String,String> map = new HashMap<>();
        List<List<String>> pcur = paths;
        for (int i = 0; i < pcur.size(); i++) {
            map.put(pcur.get(i).get(0),pcur.get(i).get(1));
        }
        String str = map.get(paths.get(0).get(0));
        while (true) {
            if (!map.containsKey(str)) {
                break;
            }
            str = map.get(str);
        }
        return str;
    }
}
